// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 2007-9-15 18:54:20


// Source File Name:   rc.java

package com.zelix;

import java.io.*;
import java.util.zip.*;


//            lx, nc, gs

public class rc
{

    private ZipOutputStream a;
    private String b;
    private boolean c;
    private InputStream d;
    private int e;
    private File f;
    private ByteArrayOutputStream g;
    private CheckedOutputStream h;
    private BufferedOutputStream i;
    private String j;
    private static String z[];

    public rc(ZipOutputStream zipoutputstream, String s, boolean flag)
    {
        a = zipoutputstream;
        b = s;
        c = flag;
        j = z[1];
    }

    public rc(ZipOutputStream zipoutputstream, String s, boolean flag, File file)
    {
        a = zipoutputstream;
        b = s;
        c = flag;
        f = file;
        j = z[0];
    }

    public rc(ZipOutputStream zipoutputstream, String s, boolean flag, InputStream inputstream, int k)
    {
        a = zipoutputstream;
        b = s;
        c = flag;
        d = inputstream;
        e = k;
        j = z[4];
    }

    public OutputStream a()
    {
        if(i == null)
        {
            g = new ByteArrayOutputStream();
            h = new CheckedOutputStream(g, new CRC32());
            i = new BufferedOutputStream(h);
        }
        j += "<";
        return i;
    }

    public void b()
        throws IOException
    {
        ZipEntry zipentry;
        BufferedInputStream bufferedinputstream;
        int l1;
        l1 = nc.h;
        zipentry = new ZipEntry(b);
        zipentry.setMethod(c ? 8 : 0);
        if(c && g == null)
            break MISSING_BLOCK_LABEL_432;
        if(f == null)
            break MISSING_BLOCK_LABEL_243;
        bufferedinputstream = null;
        byte abyte2[];
        int k1;
        bufferedinputstream = new BufferedInputStream(new FileInputStream(f));
        int k = bufferedinputstream.available();
        abyte2 = new byte[1024];
        CRC32 crc32_1 = new CRC32();
        while((k1 = bufferedinputstream.read(abyte2)) >= 0) 
            crc32_1.update(abyte2, 0, k1);
        bufferedinputstream.close();
        zipentry.setCrc(crc32_1.getValue());
        zipentry.setSize(k);
        a.putNextEntry(zipentry);
        bufferedinputstream = new BufferedInputStream(new FileInputStream(f));
        if(l1 == 0) goto _L2; else goto _L1
_L1:
        int i2 = gs.b;
        gs.b = ++i2;
_L4:
        a.write(abyte2, 0, k1);
_L2:
        if((k1 = bufferedinputstream.read(abyte2)) >= 0) goto _L4; else goto _L3
_L3:
        break MISSING_BLOCK_LABEL_642;
        local;
        if(bufferedinputstream != null)
            try
            {
                bufferedinputstream.close();
            }
            catch(IOException _ex) { }
        JVM INSTR ret 4;
        byte abyte0[];
label0:
        {
            if(g != null)
            {
                i.flush();
                abyte0 = g.toByteArray();
                g.close();
                if(l1 == 0)
                    break label0;
            }
            try
            {
                abyte0 = new byte[e];
                int i1;
                for(int l = 0; l < e && (i1 = d.read(abyte0, l, Math.min(8192, e - l))) != -1; l += i1);
            }
            finally
            {
                if(d != null)
                    try
                    {
                        d.close();
                    }
                    catch(IOException _ex) { }
            }
        }
        if(!c)
        {
            CRC32 crc32 = new CRC32();
            crc32.update(abyte0);
            zipentry.setCrc(crc32.getValue());
            zipentry.setSize(abyte0.length);
        }
        a.putNextEntry(zipentry);
        a.write(abyte0, 0, abyte0.length);
        if(l1 == 0)
            break MISSING_BLOCK_LABEL_642;
        a.putNextEntry(zipentry);
        Object obj = null;
        try
        {
            if(d == null)
            {
                lx.b(f, "(" + (d == null) + "," + (g == null) + z[2] + j + z[3] + c + ")");
                String s = f.getAbsolutePath();
                d = new BufferedInputStream(new FileInputStream(f));
            }
            byte abyte1[] = new byte[1024];
            int j1;
            while((j1 = d.read(abyte1)) >= 0) 
                a.write(abyte1, 0, j1);
        }
        finally
        {
            if(d != null)
                try
                {
                    d.close();
                }
                catch(IOException _ex) { }
        }
        a.flush();
        a.closeEntry();
        return;
    }
                 private static String z(char[] chs) {
        for (int i = 0; i < chs.length; i++) {
            byte key = 0;
            switch (i % 5) {
                case 0:
                    key = 0x44;
                    break;
                case 1:
                    key = 70;
                    break;
                case 2:
                    key = 8;
                    break;
                case 3:
                    key = 21;
                    break;
                default:
                    key = 10;
                    break;
            }
            chs[i] ^= key;
        }
        return new String(chs).intern();
    }
    static 
    {
        String as[];
        as = new String[5];
        as[0] = "\002\017DP";
        as[1] = "\006\007GF";
        as[2] = "ha";
        as[3] = "cj";
        as[4] = "\r\025";
        for (int i = 0; i < as.length; i++) {
            as[i] = z(as[i].toCharArray());
        }
        z = as;

    }
}